#import <GraphicsServices/GraphicsServices.h>
#import <UIKit/UIImage.h>
#import <UIKit/UIImageView.h>

#define PANEL_SHOW_DELAY	0.5

@interface InputPanel: UIImageView
{
	id delegate;
	
	UIImage *panelNum, *panelNum0, *panelNum1, *panelNum2, *panelNum3, *panelNum4, *panelNum5, *panelNum6, *panelNum7, *panelNum8, *panelNum9, *panelNumAsterisk, *panelNumSharp;
	UIImage *panelKana, *panelKana0, *panelKana1, *panelKana2, *panelKana3, *panelKana4, *panelKana5, *panelKana6, *panelKana7, *panelKana8, *panelKana9, *panelKanaAsterisk, *panelKanaSharp;
	
	int pressedKey;
	char prevChar[3];	// xya
	
	int currentMode;
	
	enum Mode
	{
		Mode_Num, Mode_Kana,
	};
	
	enum Key
	{
		Key_0, Key_1, Key_2, Key_3, Key_4, Key_5, Key_6, Key_7, Key_8, Key_9,
		Key_Asterisk, Key_Sharp,
	};
	
	NSTimer *panelTimer;
	
	/* mouse cursor */
	BOOL cursorOperation;
	
	// single finger
	CGPoint prevPoint;
	CGPoint mouseDownPoint;
	double mouseDownTime, mouseUpTime;
	
	BOOL mouseMoved;
	
	// drag
	BOOL leftDragging, rightDragging;
	
	// gesture
	CGPoint gesStart1, gesStart2, gesEnd1, gesEnd2;
	CGPoint prevP1, prevP2;
	double gesStartTime;
	
	// click timer
	NSTimer *leftClickTimer, *rightClickTimer;
}

- (id)initWithFrame: (CGRect)frame;
- (void)dealloc;

- (int)toggleMode;

- (void)setDelegate: (id)d;
- (id)delegate;

- (void)mouseDown: (GSEventRef)e;
- (void)mouseDragged: (GSEventRef)event;
- (void)mouseUp: (GSEventRef)e;

- (BOOL)canHandleGestures;
- (void)gestureStarted: (GSEventRef)event;
- (void)gestureEnded: (GSEventRef)event;
- (void)gestureChanged: (GSEventRef)event;

- (void)sendMouseLeftButtonClick: (NSTimer *)timer;
- (void)sendMouseRightButtonClick: (NSTimer *)timer;

- (void)showPanel: (NSTimer *)timer;

@end
